﻿using Microsoft.Extensions.Logging;

namespace Huasky.MyWrod.Common.Util;

public static class LoggerHelper
{
    private static ILogger _logger;

    public static void Init(ILoggerFactory factory)
    {
        if (_logger != null)
            return;

        _logger = factory.CreateLogger("Huasky.MyWrod");
    }

    public static ILogger Logger => _logger;


    public static IDisposable BeginScope<TState>(TState state) where TState : notnull
    {
        return _logger.BeginScope(state);
    }

    public static void Error(Exception e, string format, params object[] args)
    {
        _logger.LogError(e, format, args);
    }

    public static void Error(Exception e)
    {
        _logger.LogError(e, string.Empty);
    }

    public static void Error(string format, params object[] args)
    {
        _logger.LogError(format, args);
    }

    public static void Info(string format, params object[] args)
    {
        _logger.LogInformation(format, args);
    }

    public static void Warning(string format, params object[] args)
    {
        _logger.LogWarning(format, args);
    }

    public static void Debug(string format, params object[] args)
    {
        _logger.LogDebug(format, args);
    }
}
